import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Socket from '@/utils/socket'

// 创建 WebSocket 实例
const socket = new Socket()
window.socketInstance = socket

// element-ui
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.config.productionTip = false
Vue.use(ElementUI)

import 'quill/dist/quill.core.css' // 基本样式（必需）
import 'quill/dist/quill.snow.css' // 主题样式（可选）
import 'quill/dist/quill.bubble.css' // 另一种主题样式（可选）

// 自定义库
import '@/assets/icons'
import '@/assets/css/customStyle.css'
import '@/assets/css/commonUI.css'
import '@/assets/css/animate.css'
import '@/assets/style/variable.module.scss'

// main.js - 更严格的拦截
const originalAddEventListener = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(type, listener, options) {
  // 拦截所有废弃的 mutation events
  const deprecatedEvents = [
    'DOMNodeInserted',
    'DOMNodeRemoved', 
    'DOMAttrModified',
    'DOMCharacterDataModified',
    'DOMSubtreeModified',
    'DOMNodeInsertedIntoDocument',
    'DOMNodeRemovedFromDocument'
  ];
  
  if (deprecatedEvents.includes(type)) {
    // 完全阻止这些事件的注册
    return;
  }
  originalAddEventListener.call(this, type, listener, options);
};

// 同时拦截 removeEventListener
const originalRemoveEventListener = EventTarget.prototype.removeEventListener
EventTarget.prototype.removeEventListener = function(type, listener, options) {
  const deprecatedEvents = [
    'DOMNodeInserted',
    'DOMNodeRemoved', 
    'DOMAttrModified',
    'DOMCharacterDataModified',
    'DOMSubtreeModified',
    'DOMNodeInsertedIntoDocument',
    'DOMNodeRemovedFromDocument'
  ]
  
  if (deprecatedEvents.includes(type)) return
  originalRemoveEventListener.call(this, type, listener, options)
}

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
